package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.bank.CheckingAccount;
import com.acme.bankapp.domain.bank.Client;
import com.acme.bankapp.domain.bank.Gender;
import com.acme.bankapp.domain.bank.SavingAccount;
import com.acme.bankapp.domain.exceptions.ClientExistsException;
import com.acme.bankapp.domain.exceptions.NotEnoughFundsException;
import com.acme.bankapp.domain.exceptions.OverDraftLimitExceededException;

public class BankApplication {	
	
	public static void modifyBank(Bank bank) {
		try{
			Client bank_client1, bank_client2;
			bank_client1 = bank.getClient(0);
			bank_client2 = bank.getClient(1);			
			bank_client1.getAccount(0).withdraw(1250);
			bank_client2.getAccount(0).deposit(345);
		}
		catch (IllegalArgumentException e) {
			System.out.println("The Exception" + e.getMessage() + " has occured");
		}
		catch (OverDraftLimitExceededException e) {
			System.out.println("The Exception OverDraftLimitExceededException has occured");
			System.out.println("request exceeded balance on " + e.getAmount());
		} catch (NotEnoughFundsException e) {			
			System.out.println(e.getMessage());
		}
	}

	
	public static void main(String[] args) {
		
		BankService bs = new BankService();
		Bank SberBank = new Bank();		
		
		int id = SberBank.getNumClients();
		Client client1 = new Client (new CheckingAccount(id + 1), 10, "Smith", Gender.FEMALE); 
		Client client3 = new Client (new CheckingAccount(id + 1), 10, "Smith", Gender.FEMALE); 
		Client client2 = new Client (new SavingAccount(id + 3), 100.124, "Smith", Gender.MALE);
		
		if (client1.equals(client3)) {
			System.out.println(client1 + "\n" + " equals to " + client2);
		}
		
		if (client1 != client3) {
			System.out.println("Clients have different referencies");
		}
				
		try{
			bs.addClient(SberBank, client1);
			bs.addClient(SberBank, client2);
		}
		catch (ClientExistsException e) {
			System.out.println("The Exception" + e.getMessage() + " has occured");
		}
	}

}
